package com.example.demo.UniqueTest;

public class UniqueController {
    public static void main(String[] args) throws InterruptedException {

        // 测试:100个线程，每个线程负责生成10w个id
//        long startTime = System.currentTimeMillis();
//        CountDownLatch countDownLatch=new CountDownLatch(10000000);
//        final SnowFlake idWorker = new SnowFlake(0, 0);
//        Set set = Collections.synchronizedSet(new HashSet());
//        for (int i = 0; i < 100; i++) {
//            Thread thread = new Thread(() -> {
//                for (int i1 = 0; i1 < 100000; i1++) {
//                    long id = idWorker.nextId();
//                    System.out.println("id:"+id);
//                    set.add(id);
//                    countDownLatch.countDown();
//                }
//            });
//            thread.start();
//        }
//        countDownLatch.await();
//        long endTime = System.currentTimeMillis();
//        System.out.println("set.size():" + set.size());
//        System.out.println("endTime-startTime:" + (endTime - startTime));


    }
}
